package com.university.controller;

import com.university.infrastructure.Result;
import com.university.pojo.cqe.command.CmdLogin;
import com.university.pojo.dto.UserDTO;
import com.university.pojo.entity.User;
import com.university.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Date: 2021/5/13 0:03
 * @Description:
 */
@Api(tags = {"用户接口"})
@RestController
public class UserController extends BaseController {

    @Resource
    private UserService userService;

    @ApiOperation("管理员登录")
    @PostMapping("/admin/login")
    public Result login(@RequestBody CmdLogin model) {
        User user = userService.login(model.getUsername(), model.getPassword());
        return ok(user, UserDTO.class);
    }

}
